package com.yjc.springcloud.alibaba.controller;

import com.yjc.springcloud.alibaba.domain.CommonResult;
import com.yjc.springcloud.alibaba.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author shkstart
 * @create 2022-08-18 8:42
 */
@RestController
@Slf4j
public class AccountController {
    @Autowired
    AccountService accountService;

    @GetMapping("/account/decrease")
    public CommonResult decreaseAccount(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money) throws InterruptedException {
        accountService.decreaseAccount(userId, money);
        return new CommonResult(200, "余额扣除成功~~~");
    }
}
